with Ada.Command_line; use Ada.Command_Line;
with PajekFileProcess; use PajekFilePRocess;
with Ada.Strings; use Ada.Strings;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Exceptions; use Ada.Exceptions;
with Ada.Text_Io; use Ada.Text_Io;
with Ada.Integer_Text_Io; use Ada.Integer_Text_Io;
with Travellers; use Travellers; 

procedure networktravellers is
    network: NodeListPointer; 
    filename: Unbounded_String; 
    first: Positive;
begin
    if Argument_count>2 then    
                    -- determine filename without extension
                    first:=index(to_unbounded_string(Argument(1)),".net");
                    filename:=head(to_unbounded_string(Argument(1)),first-1 ,' ');
            
                    Put_Line("Parsing file: " & to_string(filename));
                    -- Load Pajek File
                    network:=LoadPajekFile(Argument(1));
                    Put_Line("File Parsed");
                    declare
                        type P_T is access Traveller;
                    begin
                        Put("Number of travellers to create is ");Put(Argument(2));Put_line("");
                    end;      
                    declare
                        tmp: TravellerManagerPointer;
                    begin
                        tmp:=new TravellerManager(Integer'Value(Argument(3)), Integer'Value(Argument(2)),network);
                        tmp.setManager(tmp);
                        Put_line("Creating travellers");
                        tmp.CreateTravellers;
                        Put_line("Ended creation of all travellers");
                    end;               
                else
                    Put_Line("Usage: networktravellers.exe <filename>.net <numberOfTravellers> <maxConcurrentTravellers>");
                end if;
                exception
                    when Name_Error =>
                        Put(File => Standard_Error, Item => "File name not found.");
end networktravellers;